<template>
	<div class="sealList">
		<el-card class="box-card">
			<div slot="header" class="clearfix">
				<span>设备管理</span>
				<el-button style="float: right; padding: 3px 0" type="text" @click="seach_onoff = !seach_onoff">搜索按钮</el-button>
			</div>
			<div class="searchWarp" :class="seach_onoff?'animated':''">
				<el-form ref="form" label-width="100px" style="display: flex;flex-wrap: wrap;">
					<el-form-item label="关键词" :span="6" class="lz-el-col">
						<el-input placeholder="关键词" v-model="seachData.keyword" @keyup.enter.native="seachInput" size="mini"></el-input>
					</el-form-item>
					<el-form-item :span="6" class="lz-el-col">
						<el-button type="primary" size="mini" icon="el-icon-search" plain @click="seachInput">搜索</el-button>
					</el-form-item>
				</el-form>
			</div>
			<!-- :class="EditOnoff ? 'tb-edit' : 'tb-edit2'" -->
			<el-table :data="tableData" size="mini" border highlight-current-row @row-click="handleCurrentRow" @row-dblclick="handleCurrentRowdbclick">
				<el-table-column prop="createDate" label="注册时间" width="150" align="center">
					<template slot-scope="scope">
						<span>{{GLOBAL.formatDate(scope.row.createDate)}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="orgId" label="组织ID" align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="id" label="印章ID" align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="name" label="印章名称" align="center">
					<template slot-scope="scope">
						<el-input size="small" v-if="scope.row.onoff" v-model="EditBefore.name" placeholder="印章名称"></el-input>
						<span class="span" v-else>{{scope.row.name}}</span>
					</template>
				</el-table-column>
				<!-- <el-table-column prop="uuid" label="UUID" align="center" :show-overflow-tooltip="true"></el-table-column> -->
				<!-- <el-table-column prop="iccid" label="iccid" align="center" :show-overflow-tooltip="true"></el-table-column> -->
				<el-table-column prop="app.name" label="应用" align="center" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column prop="count" label="使用次数" width="80" align="center">
					<template slot-scope="scope">
						<span>{{scope.row.count||0}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="online" label="在线状态" width="80" align="center">
					<template slot-scope="scope">
						<span v-if="scope.row.online" style="background: #67c23a;color: white;padding: 4px 5px;border-radius:4px;">在线</span>
						<span v-else="" style="background: #d3d4d6;color: white;padding:4px 5px;border-radius:4px;">离线</span>
					</template>
				</el-table-column>
				<!-- <el-table-column prop="network" label="公司名称" width="70" :show-overflow-tooltip="true"></el-table-column> -->
				<el-table-column prop="network" label="网络状态" width="170" :show-overflow-tooltip="true" align="center">
					<template slot-scope="scope">
						<span>{{scope.row.network||'未知'}}</span>
					</template>
				</el-table-column>
				<el-table-column prop="location" label="印章所在地" :show-overflow-tooltip="true" align="center">
					<template slot-scope="scope" v-if="scope.row.location">
						<span>{{scope.row.location.location||'暂无'}}</span>
					</template>
				</el-table-column>
				<el-table-column fixed="right" label="操作" :show-overflow-tooltip="true" align="center" width="300">
					<template slot-scope="scope">
						<!-- <el-button @click="DeleterDevice(scope.row)" type="text" size="small" v-if="scope.row.mine">删除</el-button> -->
						<!-- <el-button type="text" size="small" @click="applicationPush(scope.row)">申请单</el-button> -->
						<el-button type="text" size="small" @click="fingerprint(scope.row)">指纹</el-button>
						<el-button type="text" size="small" @click="getWifiList(scope.row.uuid)">wifi</el-button>
						<!-- <el-button type="text" size="small" @click="unlockID(scope.row.uuid)">无指纹解锁</el-button> -->
						<!-- <el-button type="text" size="small" @click="transformModel(scope.row.uuid)">运行模式</el-button> -->
						<el-button type="text" size="small" @click="sleepSet(scope.row)">休眠时间</el-button>
						<!-- <el-button type="text" size="small" @click="deviceInit(scope.row)">设备初始化</el-button> -->
						<!-- <el-button type="text" size="small" @click="deviceLock(scope.row)">设备锁</el-button> -->
						<!-- <el-button type="text" size="small" @click="editApp(scope.row)">应用</el-button> -->
						<el-button type="text" size="small" @click="usageRecordFn(scope.row)">使用记录</el-button>
						<!-- <el-button type="text" size="small" @click="deviceLock(scope.row,0)">解锁</el-button> -->

					</template>
				</el-table-column>
			</el-table>
			<!-- //分页 -->
			<el-pagination class="lz-el-pagination" @current-change="handleCurrentChange" @size-change="handleSizeChange"
			 :current-page="page.pageNum" :page-sizes="[10,20,30]" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper"
			 :total="page.total"></el-pagination>
		</el-card>
		<!-- 指纹录入弹框 -->
		<el-dialog title="指纹信息" :visible.sync="input_fingerprint_onoff2" width="1100px" center>
			<div style="text-align: right;padding-bottom: 50px;">
				<div style="margin-bottom: 10px;">
					<el-form ref="form" label-width="100px" style="display: flex;flex-wrap: wrap;">
						<el-form-item label="关键词" class="lz-el-col">
							<el-input v-model="InputPersons.keyword" size="mini" style="width: 220px;" placeholder="请输入关键词(姓名,手机号)"
							 @keyup.enter.native="get_InputPersonsList"></el-input>
						</el-form-item>
						<el-form-item class="lz-el-col" style="display: flex;width: 500px;">
							<el-button type="primary" size="mini" icon="el-icon-search" plain @click="get_InputPersonsList">搜索</el-button>
							<el-button type="primary" plain size="mini" @click="fingerprintEnd ">指纹录入</el-button>
							<el-button type="info" plain size="mini" @click="FingerprintClear">清空指纹</el-button>
							<el-button icon="el-icon-refresh" circle @click="get_InputPersonsList" style="font-size: 12px;color: red;" size="mini"
							 :loading="refresh.loading"></el-button>
						</el-form-item>
					</el-form>

				</div>
				<el-table :data="InputPersonsList" style="width: 100%">
					<el-table-column prop="createDate" label="指纹录入日期" width="140" align="center">
						<template slot-scope="scope">
							<span>{{GLOBAL.formatDate(scope.row.createDate)}}</span>
						</template>
					</el-table-column>
					<el-table-column prop="userName" label="指纹所属人姓名" width="180" align="center"></el-table-column>
					<el-table-column prop="userId" label="指纹所属人ID" width="200" align="center"></el-table-column>
					<el-table-column prop="signetId" label="印章ID" align="center"></el-table-column>
					<el-table-column fixed="right" label="操作" width="120" align="center">
						<template slot-scope="scope">
							<el-button @click="delPersonsOK(scope.row.userId)" type="danger" plain size="small">删除指纹</el-button>
						</template>
					</el-table-column>
				</el-table>
				<el-pagination style="margin-top: 20px;float: right;" @current-change="PersonsHandleCurrentChange" @size-change="PersonsHandleSizeChange"
				 :current-page="InputPersons.pageNum" :page-sizes="[10,20,30]" :page-size="InputPersons.pageSize" layout="total, sizes, prev, pager, next, jumper"
				 :total="InputPersons.total"></el-pagination>
			</div>
		</el-dialog>
		<!--无指纹解锁 -->
		<el-dialog title="指纹" :visible.sync="input_fingerprint_onoff3" width="500px" center>
			<el-form ref="form" label-width="140px">
				<el-form-item label="用户ID" class="lz-el-col">
					<el-input v-model="enter.userId" size="mini" style="width: 220px;" placeholder="请输入用户ID"></el-input>
				</el-form-item>
				<el-form-item label="用户名" class="lz-el-col" style="width: 220px;">
					<el-input v-model="enter.userName" size="mini" style="width: 220px;" placeholder="请输入用户名" @keyup.enter.native="InputPersonsOK"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="input_fingerprint_onoff3 = false" size="mini">取 消</el-button>
				<el-button type="primary" @click="InputPersonsOK" size="mini">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 修改运行模式 -->
		<el-dialog title="修改运行模式" :visible.sync="Model.input_fingerprint_onoff" width="500px" center>
			<div style="display: flex;align-items: center;">
				<el-radio-group v-model="Model.model" style="display: flex;">
					<el-radio :label="0">申请单模式</el-radio>
					<el-radio :label="1">指纹模式</el-radio>
					<el-radio :label="2">装章模式</el-radio>
				</el-radio-group>
				<el-tooltip class="item" effect="dark" style="margin-left:50px;" content="【申请单模式】需要推送申请单才能用章;【指纹模式】可直接指纹解锁用章;【装章模式】印章处于装章状态，一般更换章头时使用"
				 placement="bottom-start">
					<i class="el-icon-warning"></i>
				</el-tooltip>
			</div>
			<span slot="footer" class="dialog-footer">
				<el-button @click="Model.input_fingerprint_onoff = false" size="mini">取 消</el-button>
				<el-button type="primary" @click="ModelOK" size="mini">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 设备锁 -->
		<el-dialog title="设备锁" :visible.sync="lock.input_fingerprint_onoff" width="500px" center>
			<el-form ref="form" label-width="140px">
				<el-form-item label="设备锁" class="lz-el-col">
					<el-radio-group v-model="lock.status" style="display: flex;margin-top: 14px;">
						<el-radio :label="0">解锁</el-radio>
						<el-radio :label="1">锁定</el-radio>
					</el-radio-group>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="lock.input_fingerprint_onoff = false" size="mini">取 消</el-button>
				<el-button type="primary" @click="deviceLockOK" size="mini">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 推送 -->
		<el-dialog title="申请单" :visible.sync="push.input_fingerprint_onoff" width="400px" center>
			<el-tabs v-model="push.activeName">
				<el-tab-pane label="推送申请单" name="first">
					<el-form ref="form" label-width="90px">
						<el-form-item label="申请单ID" class="lz-el-col">
							<el-input v-model="push.applicationId" size="mini" style="width: 220px;" placeholder="申请单ID"></el-input>
						</el-form-item>
						<el-form-item label="已用次数" class="lz-el-col">
							<el-input v-model="push.needCount" type="number" size="mini" style="width: 220px;" placeholder="已用次数"></el-input>
						</el-form-item>
						<el-form-item label="申请总次数" class="lz-el-col">
							<el-input v-model="push.totalCount" type="number" size="mini" style="width: 220px;" placeholder="申请总次数"></el-input>
						</el-form-item>
						<el-form-item label="用印人ID" class="lz-el-col">
							<el-input v-model="push.userId" size="mini" style="width: 220px;" placeholder="用印人ID"></el-input>
						</el-form-item>
					</el-form>
				</el-tab-pane>
				<el-tab-pane label="结束申请单" name="second">
					<el-form ref="form">
						<el-form-item label="申请单ID" class="lz-el-col">
							<el-input v-model="push.applicationId" size="mini" style="width: 220px;" placeholder="申请单ID"></el-input>
						</el-form-item>
					</el-form>
				</el-tab-pane>
			</el-tabs>
			<span slot="footer" class="dialog-footer">
				<el-button @click="push.input_fingerprint_onoff = false" size="mini">取 消</el-button>
				<el-button type="primary" @click="pushOK" size="mini">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 修改休眠时间 -->
		<el-dialog title="修改休眠时间" :visible.sync="sleep.input_fingerprint_onoff" width="500px" center>
			<el-form ref="form" label-width="180px">
				<el-form-item label="休眠时间" class="lz-el-col">
					<el-input-number v-model="sleep.sleep" :min="2" :max="10" :precision="0" size="mini" label="时间为整型"></el-input-number>
					<el-tooltip class="item" effect="dark" content="注意：时间类型为整型2-10之间(单位：分钟)" placement="bottom-start">
						<i class="el-icon-warning"></i>
					</el-tooltip>
				</el-form-item>

			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="Model.input_fingerprint_onoff = false" size="mini">取 消</el-button>
				<el-button type="primary" @click="sleepOK" size="mini">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 设备初始化 -->
		<el-dialog title="设备初始化" :visible.sync="Init.input_fingerprint_onoff" width="500px" center>
			<el-form ref="form" label-width="140px" label-position="right">
				<el-form-item label="组织ID" class="lz-el-col" required>
					<el-input v-model="Init.orgId" size="mini" style="width: 220px;" placeholder="初始化组织ID"></el-input>
				</el-form-item>
				<el-form-item label="组织名称" class="lz-el-col" required>
					<el-input v-model="Init.ledShow" size="mini" :maxlength="90" style="width: 220px;" placeholder="LED屏显示名称"></el-input>
					<el-tooltip class="item" effect="dark" content="注意：长度为8个字节，中文一个字2个字节" placement="bottom-start">
						<i class="el-icon-warning"></i>
					</el-tooltip>
				</el-form-item>
				<el-form-item label="起始次数" class="lz-el-col" required>
					<el-input v-model="Init.count" size="mini" @input="inputCount" type="number" style="width: 220px;" placeholder="起始次数为整型"></el-input>
				</el-form-item>
				<el-form-item label="流水号" class="lz-el-col" required>
					<el-input v-model="Init.taskId" size="mini" style="width: 220px;" placeholder="taskId流水号"></el-input>
				</el-form-item>

			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="Model.input_fingerprint_onoff = false" size="mini">取 消</el-button>
				<el-button type="primary" @click="deviceInitOK" size="mini">确 定</el-button>
			</span>
		</el-dialog>

		<!-- wifi连接 -->
		<el-dialog title="wifi连接" :visible.sync="wifi.input_fingerprint_onoff" width="500px" center>
			<el-form label-width="80px" label-position="right">
				<el-form-item label="wifi名称:" required>
					<el-input v-model="wifi.wifiName"></el-input>
				</el-form-item>
				<el-form-item label="wifi密码:">
					<el-input v-model="wifi.wifiPassword"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="wifiConnect" size="mini">立即连接</el-button>
					<el-button type="success" @click="closeWifi" size="mini">断开连接</el-button>
					<el-button type="text" @click="wifiSearch" size="mini">获取wifi列表</el-button>
				</el-form-item>
			</el-form>
			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<span>获取到的wifi列表</span>
					<el-button style="float: right; padding: 3px 0" type="text" @click="getWifiList(wifi.uuid)">刷新列表</el-button>
				</div>
				<div v-for="(item, index) in wifi.WifiList" :key="index" class="text item" @click="wifi.wifiName=item">{{ item }}</div>
			</el-card>
		</el-dialog>
		<!-- 应用app -->
		<el-dialog title="应用app" :visible.sync="app.input_fingerprint_onoff" width="400px" center>
			<el-form label-width="80px" label-position="right">
				<el-form-item label="应用app:" required>
					<el-select v-model="app.value" placeholder="请选择">
						<el-option v-for="item in app.tableData" :key="item.id" :label="item.name" :value="item.id">
						</el-option>
					</el-select>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="app.input_fingerprint_onoff = false" size="mini">取 消</el-button>
				<el-button type="primary" @click="updateApp" size="mini">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 使用记录 -->
		<el-dialog title="使用记录" :visible.sync="useRecord.input_fingerprint_onoff" width="1000px" center>
			<div style="overflow: hidden;">
				<el-form ref="form" label-width="90px" style="display: flex;flex-wrap: wrap;">
					<el-form-item label="记录类型" :span="6" style="width: 250px;">
						<el-select v-model="useRecord.seach.type" clearable size="mini" placeholder="请选择">
							<el-option label="审批记录" :value="0"></el-option>
							<el-option label="指纹记录" :value="1"></el-option>
							<el-option label="审计记录" :value="2"></el-option>
							<el-option label="超次记录" :value="3"></el-option>
							<el-option label="拆卸记录" :value="4"></el-option>
							<el-option label="超时记录" :value="5"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="组织ID" :span="6" style="width: 250px;">
						<el-input placeholder="组织ID" v-model="useRecord.seach.orgId" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="加密类型" :span="6" style="width: 250px;">
						<el-select v-model="useRecord.seach.encryptionType" clearable size="mini" placeholder="请选择">
							<el-option label="无加密" :value="0"></el-option>
							<el-option label="AES加密" :value="1"></el-option>
							<el-option label="RSA加密" :value="2"></el-option>
							<el-option label="国盾量子加密" :value="3"></el-option>
							<el-option label="国科量子加密" :value="4"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="申请单ID" :span="6" style="width: 250px;">
						<el-input placeholder="申请单ID" v-model="useRecord.seach.applicationId" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="用印地址" :span="6" style="width: 250px;">
						<el-input placeholder="用印地址" v-model="useRecord.seach.location" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="用印次数" :span="6" style="width: 250px;">
						<el-input placeholder="用印次数" v-model="useRecord.seach.count" size="mini"></el-input>
					</el-form-item>
					<el-form-item label="用印人姓名" :span="6" style="width: 250px;">
						<el-input placeholder="用印人姓名" v-model="useRecord.seach.userName" size="mini"></el-input>
					</el-form-item>
					<el-form-item :span="6" style="width: 250px;">
						<el-button type="primary" size="mini" icon="el-icon-search" plain @click="useRecordseachInput">搜索</el-button>
					</el-form-item>
				</el-form>
				<el-table :data="useRecord.tableData" size="mini" border>
					<el-table-column property="realTime" label="用印日期" width="155" align="center"></el-table-column>
					<el-table-column property="orgId" label="组织ID" align="center" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column property="deviceId" label="设备ID" align="center" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column prop="applicationId" label="申请单ID" align="center" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column property="userName" label="用印人" align="center" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column property="count" label="用印次数" align="center" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column property="type" label="记录类型" align="center" :show-overflow-tooltip="true">
						<template slot-scope="scope">
							<el-tag size="mini" type="success" plain v-if="scope.row.type==0">审批记录</el-tag>
							<el-tag size="mini" type="success" plain v-if="scope.row.type==1">指纹记录</el-tag>
							<el-tag size="mini" type="success" plain v-if="scope.row.type==2">审计记录</el-tag>
							<el-tag size="mini" type="success" plain v-if="scope.row.type==3">超次记录</el-tag>
							<el-tag size="mini" type="success" plain v-if="scope.row.type==4">拆卸记录</el-tag>
							<el-tag size="mini" type="success" plain v-if="scope.row.type==5">超时记录</el-tag>
						</template>
					</el-table-column>
					<el-table-column property="location" label="用印地址" align="center" :show-overflow-tooltip="true"></el-table-column>

					<el-table-column property="file" label="用印图片" align="center" :show-overflow-tooltip="true">
						<template slot-scope="scope">
							<el-image v-if="scope.row.file" style="width: 50px; height: 50px" :src="`${scope.row.file.fileUrl}?Authorization=${userInfo.token}&download=0`"
							 :preview-src-list="[scope.row.file.fileUrl+'?Authorization='+userInfo.token+'download=0']"></el-image>
						</template>
					</el-table-column>
					<el-table-column property="synchState" label="记录上传" width="80" align="center" :show-overflow-tooltip="true">
						<template slot-scope="scope">
							<el-tag size="mini" type="warning" plain v-if="scope.row.synchState==0">未知</el-tag>
							<el-tag size="mini" type="success" plain v-if="scope.row.synchState==1">成功</el-tag>
							<div style="cursor: pointer;" @mouseleave="mouseleaveFn(scope.row,0)" @mouseover="mouseOverFn(scope.row,0)"
							 @click="aginClickFn(scope.row,0)">
								<el-tag size="mini" :type="scope.row.synchStateText=='失败'?'danger':'primary'" plain v-if="scope.row.synchState!=1&&scope.row.synchState!=0">{{scope.row.synchStateText}}</el-tag>
							</div>
						</template>
					</el-table-column>
					<el-table-column property="bindTask.status" label="图片上传" width="70" align="center" :show-overflow-tooltip="true">
						<template slot-scope="scope">
							<div v-if="scope.row.bindTask">
								<el-tag size="mini" type="warning" plain v-if="scope.row.bindTask.status==0">未知</el-tag>
								<el-tag size="mini" type="success" plain v-if="scope.row.bindTask.status==1">成功</el-tag>
								<div style="cursor: pointer;" v-if="scope.row.bindTask.status!=1&&scope.row.bindTask.status!=0" @mouseleave="mouseleaveFn(scope.row,1)"
								 @mouseover="mouseOverFn(scope.row,1)" @click="aginClickFn(scope.row,1)">
									<el-tag size="mini" :type="scope.row.bindTask.statusText=='失败'?'danger':'primary'" plain>{{scope.row.bindTask.statusText}}</el-tag>
								</div>
							</div>
						</template>
					</el-table-column>
				</el-table>
				<!-- //分页 -->
				<el-pagination class="lz-el-pagination" @current-change="useRecordhandleCurrentChange" @size-change="useRecordhandleSizeChange"
				 :current-page="useRecord.page.pageNum" :page-sizes="[10,20,30]" :page-size="useRecord.page.pageSize" layout="total, sizes, prev, pager, next, jumper"
				 :total="useRecord.page.total"></el-pagination>
			</div>
		</el-dialog>
		<!-- 重试信息 -->
		<el-dialog title="重试信息" :visible.sync="retry.input_fingerprint_onoff" width="800px" center>
			<el-collapse v-model="retry.activeNames">
				<el-collapse-item title="请求URL" name="4">
					<div style="text-indent: 1em;">
						<el-link type="primary" >{{retry.data.url}}</el-link>
					</div>
				</el-collapse-item>
				
				<el-collapse-item title="请求参数" name="2">
					<div style="text-indent: 1em;">
						<el-link type="primary" >{{retry.data.params}}</el-link>
					</div>
				</el-collapse-item>
				<el-collapse-item title="重试次数" name="1">
					<div style="text-indent: 1em;">
						<el-link type="primary" >{{retry.data.count}}</el-link>
					</div>
				</el-collapse-item>
				<el-collapse-item title="执行状态" name="3">
					<div style="text-indent: 2em;">
						<el-button type="success" plain size="mini" :loading="retry.load">{{retry.data.status}}</el-button>
					</div>
				</el-collapse-item>
			</el-collapse>
			<span slot="footer" class="dialog-footer">
				<el-button @click="retry.input_fingerprint_onoff = false" size="mini">取消重试</el-button>
				<el-button type="primary" @click="retrySubmit" size="mini" :loading="retry.load">确认重试</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	let that
	//非父子组件传值
	import bus from '../../../../static/js/bus.js';
	import {
		mapActions,
		mapGetters
	} from 'vuex';
	export default {
		computed: {
			...mapGetters(['userInfo', 'api']) //获取
		},
		components: {},
		data() {
			return {
				editText: '', //全局要修改印章名称
				EditOnoff: false, //表格是否可编辑
				EditBefore: {
					name: '',
					id: '',
				}, //
				seach_onoff: false, //
				seachData: {
					keyword: '', //关键词
				},
				tableData: [], //表格数据
				page: { //分页
					pageNum: 1, //当前页数
					pageSize: 10, //默认一页展示10条
					total: 0, //总条数
				},
				// 指纹录入弹框
				input_fingerprint_onoff2: false, //指纹
				InputPersonsList: [], //录入人列表
				InputPersons: { //指纹信息
					keyword: '', //搜索关键词
					pageNum: 1, //分页中当前第几页
					pageSize: 10,
					total: 0, //分页数据
					uuid: '', //印章id
				},
				input_fingerprint_onoff3: false, //指纹录入
				enter: { //指纹录入
					type: 2, //类型1为无指纹解锁，2指纹解锁
					userId: '', //用户id
					userName: '', //用户名
					uuid: '',
				},
				wifi: {
					//wifi连接
					input_fingerprint_onoff: false,
					WifiList: [],
					wifiName: '', //wifi名
					uuid: '',
					wifiPassword: '' //密码
				},
				Model: { //运行模式
					input_fingerprint_onoff: false,
					model: 0, //模式值 0:仅审批模式 1:审批+指纹模式 2:拆章模式
					uuid: '',
				},
				sleep: { //休眠时间
					input_fingerprint_onoff: false,
					sleep: 1,
					uuid: '',
				},
				Init: { //设备初始化
					input_fingerprint_onoff: false,
					count: 1, //当前印章使用次数
					ledShow: '', //led屏显示名称
					orgId: '', //初始化组织ID
					uuid: '',
					taskId: '', //流水号
				},
				push: { //推送申请单
					activeName: 'first',
					input_fingerprint_onoff: false,
					applicationId: '', //申请单ID
					needCount: '', //已用次数
					totalCount: '', //申请总次数
					userId: '', //用印人ID
					uuid: '', //设备UUID
				},
				lock: {
					input_fingerprint_onoff: false,
					status: 1, //0:解锁 1:锁定
					uuid: '',
				},
				//刷新
				refresh: {
					loading: false,
				},
				app: {
					input_fingerprint_onoff: false,
					value: '',
					tableData: [],
				},
				//使用记录
				useRecord: {
					input_fingerprint_onoff: false,
					tableData: [],
					page: { //分页
						pageNum: 1, //当前页数
						pageSize: 10, //默认一页展示10条
						total: 0, //总条数
					},
					seach: { //搜索
						type: '',
						orgId: '',
						encryptionType: '',
						applicationId: '',
						userName: '',
						location: '',
						count: ''
					}
				},
				//重试
				retry: {
					input_fingerprint_onoff: false,
					activeNames: ['1','2','3','4'],
					data: {},
					status:'',
					infoId:'',
					load:false
				}
			}
		},
		mounted() {
			that = this
			//获取设备列表
			that.getDeviceList()
		},
		methods: {
			//确认重试
			retrySubmit(){
				// console.log(retry);
				that.retry.load=true
				let req = {
					status: that.retry.status,
					infoId: that.retry.infoId
				}
				that.GLOBAL.doPost(that.api.GLOBAL_sealRecordInfo_retry, req).then(res => {
					if (res.code == 0) {
						that.retry.load=false
						that.retry.data = res.data
					}
				})
			},
			//重试
			aginClickFn(row, type) {
				let req = {
					status: type,
					infoId: row.id
				}
				that.GLOBAL.doGet(that.api.GLOBAL_sealRecordInfo_retryMessage, req).then(res => {
					if (res.code == 0) {
						that.retry.input_fingerprint_onoff = true
						that.retry.data = res.data
						that.retry.status=type
						that.retry.infoId=row.id
					}
				})

			},
			//鼠标移除事件
			mouseleaveFn(row, type) {
				if (type == 1) {
					row.bindTask.statusText = '失败'
				} else {
					row.synchStateText = '失败'
				}
			},
			//鼠标移入事件
			mouseOverFn(row, type) {
				if (type == 1) {
					row.bindTask.statusText = '重试'
				} else {
					row.synchStateText = '重试'
				}
			},
			//双击
			handleCurrentRowdbclick(row, column, event) {
				let that = this;
				that.tableData.forEach(item => {
					item.onoff = false
				})
				row.onoff = true
				that.EditBefore = { ...row
				}
				that.editText = row.name //存储印章名
			},
			//单击点击行
			handleCurrentRow(row, column, event) {
				let that = this;
				if (that.EditBefore.name != that.editText) {
					that.updateEdit(that.EditBefore.id, that.EditBefore.name)
					that.editText = that.EditBefore.name
				}
				if (!row.onoff || column.property != 'name') { //如果点击其他行或者当前行的其他列，都关闭当前输入框
					that.tableData.forEach(item => {
						item.onoff = false
					})
				}
			},
			//确认编辑名称
			updateEdit(deviceId, name) {
				let req = {
					deviceId: deviceId,
					name: name
				}
				that.GLOBAL.doPost(that.api.GLOBAL_device_update, req).then(res => {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
						that.getDeviceList()
					}
				})
			},
			//查看图片
			seeImage(row) {
				console.log(row);
			},
			//推送申请单
			applicationPush(row) {
				that.push.input_fingerprint_onoff = true
				that.push.uuid = row.uuid
			},
			pushOK() {
				let url
				if (that.push.activeName == 'first') {
					url = that.api.GLOBAL_device_applicationPush
				} else {
					url = that.api.GLOBAL_device_applicationClose
				}
				that.GLOBAL.doPost(url, that.push).then(res => {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
					}
				})
			},
			//限制使用次数
			inputCount() {
				if (that.Init.count.length > 7) {
					that.Init.count = that.Init.count.slice(0, 7)
				}
			},
			//设备锁定
			deviceLock(row) {
				that.lock = {
					input_fingerprint_onoff: true,
					uuid: row.uuid
				}

			},
			//修改应用app
			editApp(row) {
				that.app.input_fingerprint_onoff = true
				that.app.uuid = row.uuid
				that.app.value = row.app.id
				//获取应用列表
				that.getAppList()
			},
			//点击使用记录
			usageRecordFn(row) {
				//初始化使用记录参数
				that.initusageRecordFn()
				that.useRecord.input_fingerprint_onoff = true
				console.log(row);
				that.useRecord.deviceId = row.id
				//获取使用记录数据
				that.getUsageRecordFn()
			},
			//初始化使用记录参数
			initusageRecordFn() {
				that.useRecord = {
					input_fingerprint_onoff: false,
					tableData: [],
					page: { //分页
						pageNum: 1, //当前页数
						pageSize: 10, //默认一页展示10条
						total: 0, //总条数
					},
					seach: { //搜索
						type: '',
						orgId: '',
						encryptionType: '',
						applicationId: '',
						userName: '',
						location: '',
						count: ''
					}
				}
			},
			//获取使用记录数据
			getUsageRecordFn() {
				let req = {
					pageNum: that.useRecord.page.pageNum,
					pageSize: that.useRecord.page.pageSize,
					page: true,
					deviceId: that.useRecord.deviceId,
					...that.useRecord.seach
				}
				that.GLOBAL.doGet(that.api.GLOBAL_sealRecordInfo_list, req).then(res => {
					if (res.code == 0 && res.data) {
						that.useRecord.page.total = res.data.total
						res.data.list.forEach(item => {
							if (item.bindTask && item.bindTask.status != 1 && item.bindTask.status != 0) {
								item.bindTask.statusText = '失败'
							}
							if (item.synchState != 1 && item.synchState != 0) {
								item.synchStateText = '失败'
							}
						})
						that.useRecord.tableData = res.data.list

					} else {
						that.useRecord.tableData = []
					}
				})
			},
			//搜索使用记录
			useRecordseachInput() {
				that.useRecord.page.pageNum = 1
				//获取使用记录数据
				that.getUsageRecordFn()
			},
			//确定绑定应用APP
			updateApp() {
				let req = {
					uuid: that.app.uuid,
					appId: that.app.value
				}
				that.GLOBAL.doPost(that.api.GLOBAL_device_bindApp, req).then(res => {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
						that.app.input_fingerprint_onoff = false
						//获取设备列表
						that.getDeviceList()
					}
				})
			},
			//获取应用列表
			getAppList() {
				let req = {
					page: false,
				}
				that.GLOBAL.doGet(that.api.GLOBAL_app_get, req).then(res => {
					if (res.code == 0 && res.data) {
						that.app.tableData = res.data
					}
				})
			},
			deviceLockOK() {
				that.GLOBAL.doPost(that.api.GLOBAL_device_lock, that.lock).then(res => {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
					}
				})
			},
			//设备初始化
			deviceInit(row) {
				that.Init.uuid = row.uuid
				that.Init.input_fingerprint_onoff = true
			},
			deviceInitOK() {
				if (that.Init.orgId && that.Init.ledShow && that.Init.count && that.Init.taskId) {
					that.GLOBAL.doPost(that.api.GLOBAL_device_init, that.Init).then(res => {
						if (res.code == 0) {
							that.$message({
								message: res.message,
								type: 'success'
							});
						}
					})
				} else {
					that.$message({
						message: '*为必填项',
						type: 'warning'
					});
				}

			},
			//休眠时间
			sleepSet(row) {
				that.sleep.uuid = row.uuid
				that.sleep.sleep = row.sleepTime
				that.sleep.input_fingerprint_onoff = true
			},
			sleepOK() {
				that.GLOBAL.doPost(that.api.GLOBAL_device_sleepSet, that.sleep).then(res => {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
					}
				})
			},
			//运行模式
			transformModel(uuid) {
				that.Model.uuid = uuid
				that.Model.input_fingerprint_onoff = true
			},
			//确认运行模式
			ModelOK() {
				that.GLOBAL.doPost(that.api.GLOBAL_device_transformModel, that.Model).then(res => {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
					}
				})
			},
			//指纹录入
			fingerprintEnd() {
				that.enter.type = 1
				that.enter.uuid = that.InputPersons.uuid
				that.input_fingerprint_onoff3 = true
			},
			//无指纹录入
			unlockID(uuid) {
				console.log(uuid);
				that.enter.type = 2
				that.enter.uuid = uuid
				that.input_fingerprint_onoff3 = true
			},
			//获取设备列表
			getDeviceList() {
				let req = {
					page: true,
					pageNum: that.page.pageNum,
					pageSize: that.page.pageSize,
					keyword: that.seachData.keyword
				}
				that.GLOBAL.doGet(that.api.GLOBAL_device_getDeviceInfo, req).then(res => {
					console.log(res);
					if (res.code == 0 && res.data) {
						res.data.list.forEach(item => {
							item.onoff = false
						})
						that.tableData = res.data.list
						that.page.total = res.data.total; //总条数
					} else {
						that.tableData = []
						that.page.total = 0; //总条数
					}
				})
			},
			//点击指纹
			fingerprint(row) {
				console.log(row);
				//初始化搜索数据
				this.InputPersons = { //指纹信息
					departmentId: '', //搜索组织ID
					keyword: '', //搜索关键词
					pageNum: 1, //分页中当前第几页
					pageSize: 10,
					total: 0, //分页数据
					uuid: '', //印章id
				}
				this.InputPersons.uuid = row.uuid;
				that.input_fingerprint_onoff2 = true
				//获取录入的用户列表信息
				this.get_InputPersonsList();
			},
			//获取录入的用户列表信息
			get_InputPersonsList() {
				let req = {
					page: true,
					pageNum: that.InputPersons.pageNum,
					pageSize: that.InputPersons.pageSize,
					uuid: that.InputPersons.uuid
				}
				that.GLOBAL.doGet(that.api.GLOBAL_finger_getFingers, req, function(res) {
					if (res.code == 0 && res.data) {
						that.InputPersonsList = res.data.list
						that.InputPersons.total = res.data.total; //总条数
					}
				});
			},
			//指纹录入确认
			InputPersonsOK(userId) {
				if (that.enter.userId == 0) {
					that.$message({
						message: '用户id不能为0',
						type: 'warning'
					});
					return
				}
				let url = ''
				if (that.enter.type == 1) { //指纹录入
					url = that.api.GLOBAL_device_fingerAdd
				} else { //无指纹解锁
					url = that.api.GLOBAL_device_unlockID
				}
				let req = {
					userId: that.enter.userId,
					userName: that.enter.userName,
					uuid: that.enter.uuid
				}
				//指纹录入
				that.GLOBAL.doPost(url, req, function(res) {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
					}
				});

			},
			//指纹删除
			delPersonsOK(userId) {
				let that = this
				that.$confirm(' 是否删除当前选择的指纹？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					let req = {
						userId: userId,
						uuid: that.InputPersons.uuid
					}
					//指纹删除
					that.GLOBAL.doPost(that.api.GLOBAL_device_fingerDel, req, function(res) {
						if (res.code == 0) {
							that.$message({
								message: res.message,
								type: 'success'
							});
						}
					});
				});
			},
			//指纹全部清除
			FingerprintClear() {
				let that = this;
				that.$confirm('是否清除全部指纹?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					})
					.then(() => {
						that.GLOBAL.doPost(that.api.GLOBAL_device_fingerClear, {
							uuid: that.InputPersons.uuid
						}, function(res) {
							if (res.code == 0) {
								that.$message({
									message: res.message,
									type: 'success'
								});
							}
						});
					})
					.catch(() => {});
			},
			//获取wifi列表
			getWifiList(uuid) {
				let that = this;
				that.wifi.uuid = uuid
				that.wifi.input_fingerprint_onoff = true;
				that.wifiSearch()
			},
			//获取wifi列表
			wifiSearch() {
				that.GLOBAL.doPost(that.api.GLOBAL_device_wifiSearch, {
					uuid: that.wifi.uuid,
					page: false
				}, function(res) {
					if (res.code == 0) {
						that.wifi.WifiList = res.data;
					}
				});
			},
			//wifi连接
			wifiConnect() {
				let that = this;
				if (that.wifi.wifiName == '' || that.wifi.wifiPassword == '') {
					that.$message({
						message: 'wifi名称和密码不能为空',
						type: 'warning'
					});
					return
				}
				let req = {
					uuid: that.wifi.uuid,
					wifiName: that.wifi.wifiName,
					wifiPassword: that.wifi.wifiPassword,
				}
				that.GLOBAL.doPost(that.api.GLOBAL_device_wifiConnect, req, function(res) {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
						that.wifi.input_fingerprint_onoff = false
					}
				});
			},
			//断开wifi
			closeWifi(uuid) {
				let that = this;
				if (that.wifi.wifiName == '') {
					that.$message({
						message: '填写wifi名称',
						type: 'warning'
					});
					return
				}
				let req = {
					uuid: that.wifi.uuid,
					wifiName: that.wifi.wifiName,
				}
				that.GLOBAL.doPost(that.api.GLOBAL_device_wificlose, req, function(res) {
					if (res.code == 0) {
						that.$message({
							message: res.message,
							type: 'success'
						});
						that.wifi.input_fingerprint_onoff = false
					}
				});
			},
			//搜索
			seachInput() {
				that.page.pageNum = 1
				//获取设备列表
				that.getDeviceList()
			},
			//使用记录分页
			useRecordhandleCurrentChange(val) {
				console.log(`当前页: ${val}`);
				that.useRecord.page.pageNum = val;
				//获取使用记录数据
				that.getUsageRecordFn()
			},
			//选择一页多少条
			useRecordhandleSizeChange(val) {
				console.log(`每页 ${val} 条`);
				that.useRecord.page.pageSize = val;
				//获取使用记录数据
				that.getUsageRecordFn()
			},
			//分页
			handleCurrentChange(val) {
				console.log(`当前页: ${val}`);
				that.page.pageNum = val;
				that.getDeviceList()
			},
			//选择一页多少条
			handleSizeChange(val) {
				console.log(`每页 ${val} 条`);
				that.page.pageSize = val;
				that.getDeviceList()
			},
			//指纹删除和指纹录入分页
			PersonsHandleCurrentChange(val) {
				console.log(`当前页: ${val}`);
				that.InputPersons.pageNum = val;
				//获取录入的用户列表信息
				that.get_InputPersonsList()
			},
			//指纹选择一页多少条
			PersonsHandleSizeChange(val) {
				console.log(`每页 ${val} 条`);
				that.InputPersons.pageSize = val;
				//获取录入的用户列表信息
				that.get_InputPersonsList();
			}
		}
	}
</script>

<style scoped="scoped" lang="scss">
	.sealList {
		width: 100%;
		height: 100%;

		.searchWarp {
			transition: all 1s;
			height: 0;
			overflow: hidden;
		}

		.animated {
			height: 60px;
		}

		.box-card {
			padding-bottom: 20px;

		}

		.lz-el-pagination {
			margin-top: 20px;
			float: right;
		}
	}

	//表格的可编辑
	.tb-edit .el-input {
		display: none;
	}

	.tb-edit .el-select {
		display: none;
	}

	.tb-edit .el-switch {
		display: none;
	}

	.tb-edit .current-row .el-input {
		display: block;
	}

	.tb-edit .current-row .el-select {
		display: block;
	}

	.tb-edit .current-row .el-switch {
		display: block;
	}

	.tb-edit .current-row .el-input+span {
		display: none;
	}

	.tb-edit .current-row .el-switch+span {
		display: none;
	}

	.tb-edit .current-row .el-select+span {
		display: none;
	}

	//取消
	.tb-edit2 .current-row .el-input+span {
		display: block;
	}

	.tb-edit2 .el-input {
		display: none;
	}

	.tb-edit2 .el-select {
		display: none;
	}

	.tb-edit2 .el-switch {
		display: none;
	}
</style>
